package com.zrkj.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zrkj.entity.TSysRole;
import com.zrkj.entity.vo.Result;
import com.zrkj.service.ITSysRoleService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
 * @author : 国良
 * @className : TSysRoleController
 * @package: com.ha.controller
 * @description : 用户组表 前端控制器
 * @date :  2021-05-14
 */
@RestController
@RequestMapping(value = "/tSysRole")
@Api(tags = "角色管理")
public class TSysRoleController {
    private final ITSysRoleService itSysRoleService;

    public TSysRoleController(ITSysRoleService itSysRoleService) {
        this.itSysRoleService = itSysRoleService;
    }

    /**
     * 添加
     *
     * @param tSysRole
     * @return
     */
////    @PostMapping("/add")
//    public Result<String> add(@RequestBody TSysRole tSysRole) {
//        return itSysRoleService.add(tSysRole);
//    }

    /**
     * 角色资源站房
     * @param tSysRole
     * @return
     */
    @PostMapping("/roleResourceAndStation")
    public Result roleResourceAndStation(@RequestBody TSysRole tSysRole){
        return itSysRoleService.roleResourceAndStation(tSysRole);
    }
    /**
     * 更新
     *
     * @param tSysRole
     * @return
     */
    @PutMapping(value = "/update")
    public Result<Boolean> update(@RequestBody TSysRole tSysRole) {
        return itSysRoleService.update(tSysRole);
    }

    /**
     * 删除
     *
     * @param ids
     * @return
     */
    @DeleteMapping(value = "/delete")
    public Result<Boolean> delete(@RequestParam(value = "ids") String ids) {
        return itSysRoleService.delete(Arrays.asList(ids.split(",")));
    }

    /**
     * 查询详情
     *
     * @param id
     * @return
     */
    @GetMapping(value = "/getById/{id}")
    public Result<TSysRole> getById(@PathVariable(value = "id") String id) {
        return itSysRoleService.getById(id);
    }

    /**
     * 查询列表
     *
     * @param tSysRole
     * @return
     */
    @PostMapping(value = "/queryList")
    public Result<List<TSysRole>> queryList(@RequestBody TSysRole tSysRole) {
        return itSysRoleService.queryList(tSysRole);
    }

    @PostMapping(value = "/queryPageList")
    public Result<IPage<TSysRole>> queryPageList(@RequestBody TSysRole data) {
        return itSysRoleService.queryPageList(data);
    }
}
